package com.cloudfun.campusshare.controller;

import com.cloudfun.campusshare.common.constant.Code;
import com.cloudfun.campusshare.common.model.vo.AuthoritySimpleListVO;
import com.cloudfun.campusshare.common.response.BaseResult;
import com.cloudfun.campusshare.common.response.BaseResultFactory;
import com.cloudfun.campusshare.common.security.AuthRequired;
import com.cloudfun.campusshare.service.AuthorityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Huqin on 2020/5/13
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/v1/authority")
@Api(value = "权限模块", description = "权限模块")
@AuthRequired
public class AuthorityController {

    @Autowired
    private AuthorityService authorityService;

    @ApiOperation(value = "权限简单列表", notes = "权限简单列表")
    @GetMapping("/simpleList")
    public BaseResult<List<AuthoritySimpleListVO>> simpleList() {
        List<AuthoritySimpleListVO> res = authorityService.getSimpleList();
        return BaseResultFactory.produceResult(Code.SUCCESS, res);
    }

}
